package com.deer.wms.ware.task.dao;

import com.deer.wms.project.root.core.mapper.Mapper;
import com.deer.wms.project.root.mapper.SuperMapper;
import com.deer.wms.ware.task.model.Return.SoLogItemDto;
import com.deer.wms.ware.task.model.SO.SoDayList;
import com.deer.wms.ware.task.model.SO.SoDetail;
import com.deer.wms.ware.task.model.SO.SoDetailCriteria;
import com.deer.wms.ware.task.model.SO.SoDetailDto;
import org.apache.ibatis.annotations.Param;
import org.springframework.security.core.parameters.P;

import java.util.List;

public interface SoDetailMapper extends SuperMapper<SoDetail> {

    List<SoDetailDto> findList(SoDetailCriteria criteria);

    List<SoDetail> findByBillNo(@Param("billNo") String billNo);

    /**
     * 查询所有未完全分配的SO明细
     *
     * @return List<SoDetailDto>
     */
    List<SoDetailDto> findUndistributedSoDetail(@Param("soType") Integer soType);

    List<SoDetailDto> findDetailsByWaveId(@Param("wareId") Integer wareId, @Param("waveId") Integer waveId);

    List<SoDetail> findByMasterId(@Param("soId") Integer soId);

    List<SoDayList> findDayList(SoDetailCriteria criteria);

    List<SoDetailDto> findBaoKuanByItemCode(@Param("itemCode") String itemCode, @Param("wareId") Integer wareId, @Param("orgId") Integer orgId);

    List<SoLogItemDto> findLogItemsByBillNos(@Param("list") List<String> billNos);


    /**
     * 生产任务单号查询
     *
     * @param billNo
     * @return
     */
    List<SoDetail> findByOrderNo(String billNo);

    List<SoDetail> beBeing(@Param("itemCode") String itemCode, @Param("billNo") String billNo);

    void deleteByBillNoUda1(@Param("billNo") String billNo, @Param("erpLineNo") int erpLineNo);

    List<SoDetail> selectBillNo(@Param("billNo") String billNo);

    List<SoDetail> queryList(@Param("billNo") String billNo, @Param("erpLineNo") Integer erpLineNo, @Param("soType") int soType);

    /**
     * 批量添加从表数据
     *
     * @param soDetails
     * @return
     */
    int insertList(@Param("soDetails") List<SoDetail> soDetails);

    /**
     * 批量修改从表数据
     *
     * @param soDetails
     * @return
     */
    int updateList(@Param("soDetails") List<SoDetail> soDetails);

    List<SoDetail> queryList2(@Param("billNo") String billNo, @Param("erpLineNo") Integer erpLineNo, @Param("soType") int soType);
}